package com.study.chain.auth.builderchain;

import com.study.chain.auth.Member;

public abstract class Handler {
    protected Handler nextHandler;
    private void setNextHandler(Handler handler){
        this.nextHandler = handler;
    }
    protected abstract void doHandler(Member member);

    public static class Builder{
        private Handler head;
        private Handler tail;

        public Builder addHandler(Handler handler){
            if(this.head == null){
                this.head = this.tail = handler;
            }
            this.tail.setNextHandler(handler);
            this.tail=handler;
            return this;
        }

        public Handler build(){
            return this.head;
        }
    }
}
